﻿using System;
using Microsoft.SPOT;
using Gadgeteer.Interfaces;
using Gadgeteer.Modules.GHIElectronics;

namespace Gadgeteer.Interfaces.GHI
{
    internal class CameraWrapper : ICamera
    {
        private readonly Camera camera;

        public CameraWrapper(Camera camera)
        {
            this.camera = camera;
            camera.PictureCaptured += camera_PictureCaptured;
        }

        public void TakePicture()
        {
            this.camera.TakePicture();
        }

        void camera_PictureCaptured(Camera sender, Picture picture)
        {
            OnPictureCaptured(picture);
        }

        private void OnPictureCaptured(Picture picture)
        {
            var ev = PictureCaptured;
            if (ev != null)
                ev.Invoke(this, picture);
        }

        public event PictureCapturedEventHandler PictureCaptured;
    }
}
